package characterstream;

import java.io.*;

public class FileWriterRWSourceFileDemo {

    public static void main(String[] args) {
        Reader bin = null;
        Writer bout = null;
        File srcFile = new File("D:" + File.separator + "MyUtils.java");
        File destFile = new File("E:" + File.separator + "MyUtils.java");
        try {
            bin = new FileReader(srcFile);
            bout = new FileWriter(destFile);
            long startTime = System.currentTimeMillis();
            int ch = -1;
            while ((ch = bin.read()) != -1) { //每次读出一个字符
                bout.write(ch); //写入一个字符
            }
            long endTime = System.currentTimeMillis();
            System.out.println("总用时：" + (endTime - startTime) + "毫秒");
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            try {
                if (bin != null) {
                    bin.close();
                    bin = null;
                }
                if (bout != null) {
                    bout.close();
                    bout = null;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
}
